3.80 \(\int \frac{A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx\)

Optimal. Leaf size=140 \[ -\frac{A d^2-B c d+c^2 C}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}+\frac{\left (2 c d (A-C)-B \left (c^2-d^2\right )\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{f \left (c^2+d^2\right )^2}-\frac{x \left (-A \left (c^2-d^2\right )-2 B c d+c^2 C-C d^2\right )}{\left (c^2+d^2\right )^2} \]

[Out]

-(((c^2*C - 2*B*c*d - C*d^2 - A*(c^2 - d^2))*x)/(c^2 + d^2)^2) + ((2*c*(A - C)*d - B*(c^2 - d^2))*Log[c*Cos[e
+ f*x] + d*Sin[e + f*x]])/((c^2 + d^2)^2*f) - (c^2*C - B*c*d + A*d^2)/(d*(c^2 + d^2)*f*(c + d*Tan[e + f*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.20904, antiderivative size = 140, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 33, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.091, Rules used = {3628, 3531, 3530} \[ -\frac{A d^2-B c d+c^2 C}{d f \left (c^2+d^2\right ) (c+d \tan (e+f x))}+\frac{\left (2 c d (A-C)-B \left (c^2-d^2\right )\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{f \left (c^2+d^2\right )^2}-\frac{x \left (-A \left (c^2-d^2\right )-2 B c d+c^2 C-C d^2\right )}{\left (c^2+d^2\right )^2} \]

Antiderivative was successfully verified.

[In]

Int[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x])^2,x]

[Out]

-(((c^2*C - 2*B*c*d - C*d^2 - A*(c^2 - d^2))*x)/(c^2 + d^2)^2) + ((2*c*(A - C)*d - B*(c^2 - d^2))*Log[c*Cos[e
+ f*x] + d*Sin[e + f*x]])/((c^2 + d^2)^2*f) - (c^2*C - B*c*d + A*d^2)/(d*(c^2 + d^2)*f*(c + d*Tan[e + f*x]))

Rule 3628

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f
_.)*(x_)]^2), x_Symbol] :> Simp[((A*b^2 - a*b*B + a^2*C)*(a + b*Tan[e + f*x])^(m + 1))/(b*f*(m + 1)*(a^2 + b^2
)), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[b*B + a*(A - C) - (A*b - a*B - b*C)*Tan[e +
 f*x], x], x], x] /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && LtQ[m, -1] && NeQ[a^2
 + b^2, 0]

Rule 3531

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[((a*c +
 b*d)*x)/(a^2 + b^2), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3530

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c*Log[Re
moveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]])/(b*f), x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rubi steps

\begin{align*} \int \frac{A+B \tan (e+f x)+C \tan ^2(e+f x)}{(c+d \tan (e+f x))^2} \, dx &=-\frac{c^2 C-B c d+A d^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))}+\frac{\int \frac{A c-c C+B d+(B c-(A-C) d) \tan (e+f x)}{c+d \tan (e+f x)} \, dx}{c^2+d^2}\\ &=-\frac{\left (c^2 C-2 B c d-C d^2-A \left (c^2-d^2\right )\right ) x}{\left (c^2+d^2\right )^2}-\frac{c^2 C-B c d+A d^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))}+\frac{\left (2 c (A-C) d-B \left (c^2-d^2\right )\right ) \int \frac{d-c \tan (e+f x)}{c+d \tan (e+f x)} \, dx}{\left (c^2+d^2\right )^2}\\ &=-\frac{\left (c^2 C-2 B c d-C d^2-A \left (c^2-d^2\right )\right ) x}{\left (c^2+d^2\right )^2}+\frac{\left (2 c (A-C) d-B \left (c^2-d^2\right )\right ) \log (c \cos (e+f x)+d \sin (e+f x))}{\left (c^2+d^2\right )^2 f}-\frac{c^2 C-B c d+A d^2}{d \left (c^2+d^2\right ) f (c+d \tan (e+f x))}\\ \end{align*}

Mathematica [C]  time = 2.24105, size = 207, normalized size = 1.48 \[ \frac{(d (C-A)+B c) \left (\frac{2 d \left (\frac{c^2+d^2}{c+d \tan (e+f x)}-2 c \log (c+d \tan (e+f x))\right )}{\left (c^2+d^2\right )^2}+\frac{i \log (-\tan (e+f x)+i)}{(c+i d)^2}-\frac{i \log (\tan (e+f x)+i)}{(c-i d)^2}\right )+\frac{B ((-d-i c) \log (-\tan (e+f x)+i)+i (c+i d) \log (\tan (e+f x)+i)+2 d \log (c+d \tan (e+f x)))}{c^2+d^2}-\frac{2 C}{c+d \tan (e+f x)}}{2 d f} \]

Antiderivative was successfully verified.

[In]

Integrate[(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2)/(c + d*Tan[e + f*x])^2,x]

[Out]

((B*(((-I)*c - d)*Log[I - Tan[e + f*x]] + I*(c + I*d)*Log[I + Tan[e + f*x]] + 2*d*Log[c + d*Tan[e + f*x]]))/(c
^2 + d^2) - (2*C)/(c + d*Tan[e + f*x]) + (B*c + (-A + C)*d)*((I*Log[I - Tan[e + f*x]])/(c + I*d)^2 - (I*Log[I
+ Tan[e + f*x]])/(c - I*d)^2 + (2*d*(-2*c*Log[c + d*Tan[e + f*x]] + (c^2 + d^2)/(c + d*Tan[e + f*x])))/(c^2 +
d^2)^2))/(2*d*f)

________________________________________________________________________________________

Maple [B]  time = 0.042, size = 438, normalized size = 3.1 \begin{align*} -{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) Acd}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) B{c}^{2}}{2\,f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) B{d}^{2}}{2\,f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( fx+e \right ) \right ) ^{2} \right ) cCd}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}+{\frac{A\arctan \left ( \tan \left ( fx+e \right ) \right ){c}^{2}}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}-{\frac{A\arctan \left ( \tan \left ( fx+e \right ) \right ){d}^{2}}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}+2\,{\frac{B\arctan \left ( \tan \left ( fx+e \right ) \right ) cd}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}-{\frac{C\arctan \left ( \tan \left ( fx+e \right ) \right ){c}^{2}}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}+{\frac{C\arctan \left ( \tan \left ( fx+e \right ) \right ){d}^{2}}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}-{\frac{Ad}{f \left ({c}^{2}+{d}^{2} \right ) \left ( c+d\tan \left ( fx+e \right ) \right ) }}+{\frac{Bc}{f \left ({c}^{2}+{d}^{2} \right ) \left ( c+d\tan \left ( fx+e \right ) \right ) }}-{\frac{{c}^{2}C}{f \left ({c}^{2}+{d}^{2} \right ) d \left ( c+d\tan \left ( fx+e \right ) \right ) }}+2\,{\frac{\ln \left ( c+d\tan \left ( fx+e \right ) \right ) Acd}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}-{\frac{\ln \left ( c+d\tan \left ( fx+e \right ) \right ) B{c}^{2}}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}+{\frac{\ln \left ( c+d\tan \left ( fx+e \right ) \right ) B{d}^{2}}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}}-2\,{\frac{\ln \left ( c+d\tan \left ( fx+e \right ) \right ) cCd}{f \left ({c}^{2}+{d}^{2} \right ) ^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^2,x)

[Out]

-1/f/(c^2+d^2)^2*ln(1+tan(f*x+e)^2)*A*c*d+1/2/f/(c^2+d^2)^2*ln(1+tan(f*x+e)^2)*B*c^2-1/2/f/(c^2+d^2)^2*ln(1+ta
n(f*x+e)^2)*B*d^2+1/f/(c^2+d^2)^2*ln(1+tan(f*x+e)^2)*c*C*d+1/f/(c^2+d^2)^2*A*arctan(tan(f*x+e))*c^2-1/f/(c^2+d
^2)^2*A*arctan(tan(f*x+e))*d^2+2/f/(c^2+d^2)^2*B*arctan(tan(f*x+e))*c*d-1/f/(c^2+d^2)^2*C*arctan(tan(f*x+e))*c
^2+1/f/(c^2+d^2)^2*C*arctan(tan(f*x+e))*d^2-1/f/(c^2+d^2)*d/(c+d*tan(f*x+e))*A+1/f/(c^2+d^2)/(c+d*tan(f*x+e))*
B*c-1/f/(c^2+d^2)/d/(c+d*tan(f*x+e))*c^2*C+2/f/(c^2+d^2)^2*ln(c+d*tan(f*x+e))*A*c*d-1/f/(c^2+d^2)^2*ln(c+d*tan
(f*x+e))*B*c^2+1/f/(c^2+d^2)^2*ln(c+d*tan(f*x+e))*B*d^2-2/f/(c^2+d^2)^2*ln(c+d*tan(f*x+e))*c*C*d

________________________________________________________________________________________

Maxima [A]  time = 1.46227, size = 277, normalized size = 1.98 \begin{align*} \frac{\frac{2 \,{\left ({\left (A - C\right )} c^{2} + 2 \, B c d -{\left (A - C\right )} d^{2}\right )}{\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac{2 \,{\left (B c^{2} - 2 \,{\left (A - C\right )} c d - B d^{2}\right )} \log \left (d \tan \left (f x + e\right ) + c\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac{{\left (B c^{2} - 2 \,{\left (A - C\right )} c d - B d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac{2 \,{\left (C c^{2} - B c d + A d^{2}\right )}}{c^{3} d + c d^{3} +{\left (c^{2} d^{2} + d^{4}\right )} \tan \left (f x + e\right )}}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^2,x, algorithm="maxima")

[Out]

1/2*(2*((A - C)*c^2 + 2*B*c*d - (A - C)*d^2)*(f*x + e)/(c^4 + 2*c^2*d^2 + d^4) - 2*(B*c^2 - 2*(A - C)*c*d - B*
d^2)*log(d*tan(f*x + e) + c)/(c^4 + 2*c^2*d^2 + d^4) + (B*c^2 - 2*(A - C)*c*d - B*d^2)*log(tan(f*x + e)^2 + 1)
/(c^4 + 2*c^2*d^2 + d^4) - 2*(C*c^2 - B*c*d + A*d^2)/(c^3*d + c*d^3 + (c^2*d^2 + d^4)*tan(f*x + e)))/f

________________________________________________________________________________________

Fricas [A]  time = 1.13206, size = 566, normalized size = 4.04 \begin{align*} -\frac{2 \, C c^{2} d - 2 \, B c d^{2} + 2 \, A d^{3} - 2 \,{\left ({\left (A - C\right )} c^{3} + 2 \, B c^{2} d -{\left (A - C\right )} c d^{2}\right )} f x +{\left (B c^{3} - 2 \,{\left (A - C\right )} c^{2} d - B c d^{2} +{\left (B c^{2} d - 2 \,{\left (A - C\right )} c d^{2} - B d^{3}\right )} \tan \left (f x + e\right )\right )} \log \left (\frac{d^{2} \tan \left (f x + e\right )^{2} + 2 \, c d \tan \left (f x + e\right ) + c^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - 2 \,{\left (C c^{3} - B c^{2} d + A c d^{2} +{\left ({\left (A - C\right )} c^{2} d + 2 \, B c d^{2} -{\left (A - C\right )} d^{3}\right )} f x\right )} \tan \left (f x + e\right )}{2 \,{\left ({\left (c^{4} d + 2 \, c^{2} d^{3} + d^{5}\right )} f \tan \left (f x + e\right ) +{\left (c^{5} + 2 \, c^{3} d^{2} + c d^{4}\right )} f\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^2,x, algorithm="fricas")

[Out]

-1/2*(2*C*c^2*d - 2*B*c*d^2 + 2*A*d^3 - 2*((A - C)*c^3 + 2*B*c^2*d - (A - C)*c*d^2)*f*x + (B*c^3 - 2*(A - C)*c
^2*d - B*c*d^2 + (B*c^2*d - 2*(A - C)*c*d^2 - B*d^3)*tan(f*x + e))*log((d^2*tan(f*x + e)^2 + 2*c*d*tan(f*x + e
) + c^2)/(tan(f*x + e)^2 + 1)) - 2*(C*c^3 - B*c^2*d + A*c*d^2 + ((A - C)*c^2*d + 2*B*c*d^2 - (A - C)*d^3)*f*x)
*tan(f*x + e))/((c^4*d + 2*c^2*d^3 + d^5)*f*tan(f*x + e) + (c^5 + 2*c^3*d^2 + c*d^4)*f)

________________________________________________________________________________________

Sympy [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f*x+e))**2,x)

[Out]

Exception raised: AttributeError

________________________________________________________________________________________

Giac [B]  time = 1.58519, size = 404, normalized size = 2.89 \begin{align*} \frac{\frac{2 \,{\left (A c^{2} - C c^{2} + 2 \, B c d - A d^{2} + C d^{2}\right )}{\left (f x + e\right )}}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} + \frac{{\left (B c^{2} - 2 \, A c d + 2 \, C c d - B d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{c^{4} + 2 \, c^{2} d^{2} + d^{4}} - \frac{2 \,{\left (B c^{2} d - 2 \, A c d^{2} + 2 \, C c d^{2} - B d^{3}\right )} \log \left ({\left | d \tan \left (f x + e\right ) + c \right |}\right )}{c^{4} d + 2 \, c^{2} d^{3} + d^{5}} + \frac{2 \,{\left (B c^{2} d^{2} \tan \left (f x + e\right ) - 2 \, A c d^{3} \tan \left (f x + e\right ) + 2 \, C c d^{3} \tan \left (f x + e\right ) - B d^{4} \tan \left (f x + e\right ) - C c^{4} + 2 \, B c^{3} d - 3 \, A c^{2} d^{2} + C c^{2} d^{2} - A d^{4}\right )}}{{\left (c^{4} d + 2 \, c^{2} d^{3} + d^{5}\right )}{\left (d \tan \left (f x + e\right ) + c\right )}}}{2 \, f} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^2,x, algorithm="giac")

[Out]

1/2*(2*(A*c^2 - C*c^2 + 2*B*c*d - A*d^2 + C*d^2)*(f*x + e)/(c^4 + 2*c^2*d^2 + d^4) + (B*c^2 - 2*A*c*d + 2*C*c*
d - B*d^2)*log(tan(f*x + e)^2 + 1)/(c^4 + 2*c^2*d^2 + d^4) - 2*(B*c^2*d - 2*A*c*d^2 + 2*C*c*d^2 - B*d^3)*log(a
bs(d*tan(f*x + e) + c))/(c^4*d + 2*c^2*d^3 + d^5) + 2*(B*c^2*d^2*tan(f*x + e) - 2*A*c*d^3*tan(f*x + e) + 2*C*c
*d^3*tan(f*x + e) - B*d^4*tan(f*x + e) - C*c^4 + 2*B*c^3*d - 3*A*c^2*d^2 + C*c^2*d^2 - A*d^4)/((c^4*d + 2*c^2*
d^3 + d^5)*(d*tan(f*x + e) + c)))/f